package com.example.canopytemperature;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.example.canopytemperature.Bean.ChartLineDay;
import com.example.canopytemperature.Bean.ChartLineWeek;
import com.example.canopytemperature.Bean.ChartLineYear;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;


import com.google.gson.Gson;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

public class NodeListDetail extends AppCompatActivity {
    EditText airHumMax;
    EditText airHumMin;
    EditText airTemMax;
    EditText airTemMin;
    RadioButton airnum;
    RadioButton airtem;
    Context context;
    TextView create_time;
    int dayi = 0;
    EditText illuminaionMax;
    EditText illuminaionMin;
    RadioButton illumination;
    LineChart lineChart;
    RadioGroup node_radio_group;
    ProgressDialog progressDialog;
    RadioButton radioButton1;
    RadioGroup setChartlineRg;
    EditText soilHumMax;
    EditText soilHumMin;
    EditText soilTemMax;
    EditText soilTemMin;
    RadioButton soilhum;
    RadioButton soiltem;
    Switch switchOpen;
    int type = 0;

    /* access modifiers changed from: protected */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView((int) R.layout.activity_node_list_detail);
        initViews();
        initDatas();
        initActions();
    }

    private void initActions() {
        this.setChartlineRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                NodeListDetail.this.progressDialog.show();
                NodeListDetail nodeListDetail = NodeListDetail.this;
                nodeListDetail.type = group.indexOfChild(nodeListDetail.findViewById(checkedId));
                NodeListDetail nodeListDetail2 = NodeListDetail.this;
                nodeListDetail2.setChartLineData(nodeListDetail2.dayi, NodeListDetail.this.type);
            }
        });
        this.node_radio_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                NodeListDetail.this.progressDialog.show();
                NodeListDetail nodeListDetail = NodeListDetail.this;
                nodeListDetail.dayi = radioGroup.indexOfChild(nodeListDetail.findViewById(i));
                NodeListDetail nodeListDetail2 = NodeListDetail.this;
                nodeListDetail2.setChartLineData(nodeListDetail2.dayi, NodeListDetail.this.type);
            }
        });
        this.switchOpen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {

                if (b) {
                    String airHumMinText = NodeListDetail.this.airHumMin.getText().toString().trim();
                    String airHumMaxText = NodeListDetail.this.airHumMax.getText().toString().trim();
                    String airTemMinText = NodeListDetail.this.airTemMin.getText().toString().trim();
                    String airTemMaxText = NodeListDetail.this.airTemMax.getText().toString().trim();
                    String soilHumMinText = NodeListDetail.this.soilHumMin.getText().toString().trim();
                    String soilHumMaxText = NodeListDetail.this.soilHumMax.getText().toString().trim();
                    String soilTemMinText = NodeListDetail.this.soilTemMin.getText().toString().trim();
                    String soilTemMaxText = NodeListDetail.this.soilTemMax.getText().toString().trim();
                    String illuminaionMinText = NodeListDetail.this.illuminaionMin.getText().toString().trim();
                    String illuminaionMaxText = NodeListDetail.this.illuminaionMax.getText().toString().trim();
                    if ((TextUtils.isEmpty(airHumMinText) || TextUtils.isEmpty(airHumMaxText)) &&
                            ((TextUtils.isEmpty(airTemMinText) || TextUtils.isEmpty(airTemMaxText)) &&
                                    ((TextUtils.isEmpty(soilHumMinText) || TextUtils.isEmpty(soilHumMaxText)) &&
                                            (TextUtils.isEmpty(soilTemMinText) || TextUtils.isEmpty(soilTemMaxText))))) {

                        Toast.makeText(NodeListDetail.this, "输入值不能为空！", Toast.LENGTH_SHORT).show();
                        NodeListDetail.this.switchOpen.setChecked(false);
                        return;
                    }
                    String equ_id = NodeListDetail.this.getIntent().getStringExtra("equ_id");
                    if (!TextUtils.isEmpty(airTemMinText) || !TextUtils.isEmpty(airTemMinText)) {
                        float airTemMinFloat = Float.parseFloat(airTemMinText);
                        float airTemMaxFloat = Float.parseFloat(airTemMaxText);
                        if (airTemMinFloat >= airTemMaxFloat) {
                            Toast.makeText(NodeListDetail.this, "范围输入有误！", Toast.LENGTH_SHORT).show();
                            NodeListDetail.this.switchOpen.setChecked(false);
                            return;
                        }

                        Utils.putFloat(NodeListDetail.this.context, equ_id, "airTemMinFloat", airTemMinFloat);
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "airTemMaxFloat", airTemMaxFloat);
                    }
                    if (!TextUtils.isEmpty(airHumMinText) || !TextUtils.isEmpty(airHumMaxText)) {
                        float airHumMinFloat = Float.parseFloat(airHumMinText);
                        float airHumMaxFloat = Float.parseFloat(airHumMaxText);
                        if (airHumMinFloat >= airHumMaxFloat) {
                            Toast.makeText(NodeListDetail.this, "范围输入有误！", Toast.LENGTH_SHORT).show();
                            NodeListDetail.this.switchOpen.setChecked(false);
                            return;
                        }
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "airHumMinFloat", airHumMinFloat);
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "airHumMaxFloat", airHumMaxFloat);
                    }
                    if (!TextUtils.isEmpty(soilTemMinText) || !TextUtils.isEmpty(soilTemMinText)) {
                        float soilTemMinFloat = Float.parseFloat(soilTemMinText);
                        float soilTemMaxFloat = Float.parseFloat(soilTemMaxText);
                        if (soilTemMinFloat >= soilTemMaxFloat) {
                            Toast.makeText(NodeListDetail.this, "范围输入有误！", Toast.LENGTH_SHORT).show();
                            NodeListDetail.this.switchOpen.setChecked(false);
                            return;
                        }
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "soilTemMinFloat", soilTemMinFloat);
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "soilTemMaxFloat", soilTemMaxFloat);
                        Log.i("12121", "onCheckedChanged: "+Utils.getFloat(getApplicationContext(),equ_id,"soilTemMinFloat"));
                        Log.i("12121", "onCheckedChanged: "+Utils.getFloat(getApplicationContext(),equ_id,"soilTemMaxFloat"));
                    }
                    if (!TextUtils.isEmpty(soilHumMinText) || !TextUtils.isEmpty(soilHumMaxText)) {
                        float soilHumMinFloat = Float.parseFloat(soilHumMinText);
                        float soilHumMaxFloat = Float.parseFloat(soilHumMaxText);
                        if (soilHumMinFloat >= soilHumMaxFloat) {
                            Toast.makeText(NodeListDetail.this, "范围输入有误！", Toast.LENGTH_SHORT).show();
                            NodeListDetail.this.switchOpen.setChecked(false);
                            return;
                        }
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "soilHumMinFloat", soilHumMinFloat);
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "soilHumMaxFloat", soilHumMaxFloat);
                    }
                    if (!TextUtils.isEmpty(illuminaionMinText) || !TextUtils.isEmpty(illuminaionMaxText)) {
                        float illuminaionMinFloat = Float.parseFloat(illuminaionMinText);
                        float illuminaionMaxFloat = Float.parseFloat(illuminaionMaxText);
                        if (illuminaionMinFloat >= illuminaionMaxFloat) {
                            Toast.makeText(NodeListDetail.this, "范围输入有误！", Toast.LENGTH_SHORT).show();
                            NodeListDetail.this.switchOpen.setChecked(false);
                            return;
                        }
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "illuminaionMinFloat", illuminaionMinFloat);
                        Utils.putFloat(NodeListDetail.this.context, equ_id, "illuminaionMaxFloat", illuminaionMaxFloat);
                    }
                    NodeListDetail.this.setCheckEnabled(false);
                } else {
                    NodeListDetail.this.setCheckEnabled(true);
                    Utils.clear(NodeListDetail.this.context, NodeListDetail.this.getIntent().getStringExtra("equ_id"));
                }
                Utils.putBoolean(NodeListDetail.this.context, NodeListDetail.this.getIntent().getStringExtra("equ_id"), "switch", b);
            }
        });
    }

    /* access modifiers changed from: private */
    public void setCheckEnabled(boolean ischeck) {
        this.airHumMin.setEnabled(ischeck);
        this.airHumMax.setEnabled(ischeck);
        this.airTemMin.setEnabled(ischeck);
        this.airTemMax.setEnabled(ischeck);
        this.soilTemMin.setEnabled(ischeck);
        this.soilTemMax.setEnabled(ischeck);
        this.soilHumMin.setEnabled(ischeck);
        this.soilHumMax.setEnabled(ischeck);
        this.illuminaionMin.setEnabled(ischeck);
        this.illuminaionMax.setEnabled(ischeck);
    }

    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == 16908332) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

    private void initDatas() {
        this.progressDialog = new ProgressDialog(this.context, 3);
        this.progressDialog.setTitle("数据加载中");
        this.progressDialog.setMessage("Loading...");
        this.progressDialog.setCancelable(false);
        this.progressDialog.show();
        setChartLineData(0, 0);
        String equ_id = getIntent().getStringExtra("equ_id");
        boolean b = Utils.getBoolean(this.context, equ_id, "switch");
        this.switchOpen.setChecked(b);
        if (b) {
            if (!(((double) Utils.getFloat(this.context, equ_id, "airHumMinFloat")) == 0.0&& ((double) Utils.getFloat(this.context, equ_id, "airHumMaxFloat")) == 0.0)) {
                EditText editText = this.airHumMin;
                editText.setText(Utils.getFloat(this.context, equ_id, "airHumMinFloat") + "");
                EditText editText2 = this.airHumMax;
                editText2.setText(Utils.getFloat(this.context, equ_id, "airHumMaxFloat") + "");
            }
            if (!(((double) Utils.getFloat(this.context, equ_id, "airTemMinFloat")) == 0.0 && ((double) Utils.getFloat(this.context, equ_id, "airTemMaxFloat")) == 0.0)) {
                EditText editText3 = this.airTemMin;
                editText3.setText(Utils.getFloat(this.context, equ_id, "airTemMinFloat") + "");
                EditText editText4 = this.airTemMax;
                editText4.setText(Utils.getFloat(this.context, equ_id, "airTemMaxFloat") + "");
            }
            if (!(((double) Utils.getFloat(this.context, equ_id, "soilHumMinFloat")) == 0.0 && ((double) Utils.getFloat(this.context, equ_id, "soilHumMaxFloat")) == 0.0)) {
                EditText editText5 = this.soilHumMin;
                editText5.setText(Utils.getFloat(this.context, equ_id, "soilHumMinFloat") + "");
                EditText editText6 = this.soilHumMax;
                editText6.setText(Utils.getFloat(this.context, equ_id, "soilHumMaxFloat") + "");
            }
            if (!(((double) Utils.getFloat(this.context, equ_id, "soilTemMinFloat")) == 0.0 && ((double) Utils.getFloat(this.context, equ_id, "soilTemMaxFloat")) == 0.0)) {
                EditText editText7 = this.soilTemMin;
                editText7.setText(Utils.getFloat(this.context, equ_id, "soilTemMinFloat") + "");
                EditText editText8 = this.soilTemMax;
                editText8.setText(Utils.getFloat(this.context, equ_id, "soilTemMaxFloat") + "");
            }
            if (!(((double) Utils.getFloat(this.context, equ_id, "illuminaionMinFloat")) == 0.0 && ((double) Utils.getFloat(this.context, equ_id, "illuminaionMaxFloat")) == 0.0)) {
                EditText editText9 = this.illuminaionMin;
                editText9.setText(Utils.getFloat(this.context, equ_id, "illuminaionMinFloat") + "");
                EditText editText10 = this.illuminaionMax;
                editText10.setText(Utils.getFloat(this.context, equ_id, "illuminaionMaxFloat") + "");
            }
            setCheckEnabled(false);
        }
    }

    /* access modifiers changed from: private */
    public void setChartLineData(int i, int type2) {
        int i2 = i;
        int i3 = type2;
        final ArrayList<Entry> Daylist1 = new ArrayList<>();
        final ArrayList<Entry> Daylist2 = new ArrayList<>();
        final ArrayList<String> listTime = new ArrayList<>();
        String url = "/Greenhouse/getTimeDay?equ_id=" + getIntent().getStringExtra("equ_id");
        String url2 = "/Greenhouse/getTimeWeek?equ_id=" + getIntent().getStringExtra("equ_id");
        String url3 = "/Greenhouse/getTimeMonth?equ_id=" + getIntent().getStringExtra("equ_id");
        String url4 = "/Greenhouse/getTimeYear?equ_id=" + getIntent().getStringExtra("equ_id");

        if (i2 == 0) {

            final ArrayList<Entry> arrayList = Daylist1;
            final ArrayList<Entry> arrayList2 = Daylist2;
             final ArrayList<String> arrayList3 = new ArrayList<>();

            final int i4 = type2;
            OkHttpHelper.Get(url, new Callback() {
                public void onFailure(Call call, IOException e) {
                }

                public void onResponse(Call call, Response response) throws IOException {
                    ChartLineDay day = (ChartLineDay) new Gson().fromJson(response.body().string(), ChartLineDay.class);
                    arrayList.clear();
                    arrayList2.clear();
                    arrayList3.clear();

                    if (day.getCode() == 200) {
                        for (int j = 0; j < day.getData().getAirhum().getMax().size(); j++) {
                            int i = i4;
                            if (i == 0) {
                                arrayList.add(new Entry((float) j, day.getData().getAirtem().getMax().get(j).getAirtem()));
                                arrayList2.add(new Entry((float) j, day.getData().getAirtem().getMin().get(j).getAirtem()));
                                arrayList3.add(Utils.strToDateLong("HH时",day.getData().getAirtem().getMax().get(j).getCreate_time()));
                            } else if (i == 1) {
                                arrayList.add(new Entry((float) j, day.getData().getAirhum().getMax().get(j).getAirnum()));
                                arrayList2.add(new Entry((float) j, day.getData().getAirhum().getMin().get(j).getAirnum()));
                                arrayList3.add(Utils.strToDateLong("HH时",day.getData().getAirhum().getMax().get(j).getCreate_time()));
                            } else if (i == 2) {
                                arrayList.add(new Entry((float) j, day.getData().getSoiltem().getMax().get(j).getSoiltem()));
                                arrayList2.add(new Entry((float) j, day.getData().getSoiltem().getMin().get(j).getSoiltem()));
                                arrayList3.add(Utils.strToDateLong("HH时",day.getData().getSoiltem().getMax().get(j).getCreate_time()));
                            } else if (i == 3) {
                                arrayList.add(new Entry((float) j, day.getData().getSoilhum().getMax().get(j).getSoilhum()));
                                arrayList2.add(new Entry((float) j, day.getData().getSoilhum().getMin().get(j).getSoilhum()));
                                arrayList3.add(Utils.strToDateLong("HH时",day.getData().getSoilhum().getMax().get(j).getCreate_time()));
                            } else if (i == 4) {
                                arrayList.add(new Entry((float) j, day.getData().getIllumination().getMax().get(j).getIllumination()));
                                arrayList2.add(new Entry((float) j, day.getData().getIllumination().getMin().get(j).getIllumination()));
                                arrayList3.add(Utils.strToDateLong("HH时",day.getData().getIllumination().getMax().get(j).getCreate_time()));
                            }


                        }
//                        Log.i("TAG1111111111", "onResponse: "+arrayList3);
                        NodeListDetail.this.setChartCreate(arrayList, arrayList2,arrayList3);
                    }
                }
            });
        } else if (i2 == 1) {

            final ArrayList<Entry> arrayList4 = Daylist1;
            final ArrayList<Entry> arrayList5 = Daylist2;
            final ArrayList<String> arrayList6 = new ArrayList<>();

            final int i5 = type2;
            OkHttpHelper.Get(url2, new Callback() {
                public void onFailure(Call call, IOException e) {
                }

                public void onResponse(Call call, Response response) throws IOException {
                    ChartLineWeek day = (ChartLineWeek) new Gson().fromJson(response.body().string(), ChartLineWeek.class);
                    arrayList4.clear();
                    arrayList5.clear();
                    arrayList6.clear();

                    if (day.getCode() == 200) {
                        for (int j = 0; j < day.getData().getAirhum().getMax().size(); j++) {
                            int i = i5;
                            if (i == 0) {
                                arrayList4.add(new Entry((float) j, day.getData().getAirtem().getMax().get(j).getAirtem()));
                                arrayList5.add(new Entry((float) j, day.getData().getAirtem().getMin().get(j).getAirtem()));
                                arrayList6.add(Utils.strToDateLong("dd日",day.getData().getAirtem().getMax().get(j).getCreate_time()));
                            } else if (i == 1) {
                                arrayList4.add(new Entry((float) j, day.getData().getAirhum().getMax().get(j).getAirnum()));
                                arrayList5.add(new Entry((float) j, day.getData().getAirhum().getMin().get(j).getAirnum()));
                                arrayList6.add(Utils.strToDateLong("dd天",day.getData().getAirhum().getMax().get(j).getCreate_time()));
                            } else if (i == 2) {
                                arrayList4.add(new Entry((float) j, day.getData().getSoiltem().getMax().get(j).getSoiltem()));
                                arrayList5.add(new Entry((float) j, day.getData().getSoiltem().getMin().get(j).getSoiltem()));
                                arrayList6.add(Utils.strToDateLong("dd日",day.getData().getSoiltem().getMax().get(j).getCreate_time()));
                            } else if (i == 3) {
                                arrayList4.add(new Entry((float) j, day.getData().getSoilhum().getMax().get(j).getSoilhum()));
                                arrayList5.add(new Entry((float) j, day.getData().getSoilhum().getMin().get(j).getSoilhum()));
                                arrayList6.add(Utils.strToDateLong("dd日",day.getData().getSoilhum().getMax().get(j).getCreate_time()));
                            } else if (i == 4) {
                                arrayList4.add(new Entry((float) j, day.getData().getIllumination().getMax().get(j).getIllumination()));
                                arrayList5.add(new Entry((float) j, day.getData().getIllumination().getMin().get(j).getIllumination()));
                                arrayList6.add(Utils.strToDateLong("dd日",day.getData().getIllumination().getMax().get(j).getCreate_time()));
                            }

                        }
                        Log.i("TAG444444", "onResponse: "+arrayList6);
                        Log.i("TAG444444", "onResponse: "+arrayList5);

                        NodeListDetail.this.setChartCreate(arrayList4, arrayList5,arrayList6);
                    }
                }
            });
        } else if (i2 == 2) {

            final ArrayList<Entry> arrayList7 = Daylist1;

            final ArrayList<Entry> arrayList8 = Daylist2;
            final ArrayList<String> arrayList9 = new ArrayList<>();



            final int i6 = type2;
            OkHttpHelper.Get(url3,   new Callback() {
                public void onFailure(Call call, IOException e) {
                }

                public void onResponse(Call call, Response response) throws IOException {
                    ChartLineWeek day = (ChartLineWeek) new Gson().fromJson(response.body().string(), ChartLineWeek.class);
                    arrayList7.clear();
                    arrayList8.clear();
                    arrayList9.clear();

                    if (day.getCode() == 200) {
                        for (int j = 0; j < day.getData().getAirtem().getMax().size(); j++) {
                            int i = i6;
                            if (i == 0) {
                                arrayList7.add(new Entry((float) j, day.getData().getAirtem().getMax().get(j).getAirtem()));
                                arrayList8.add(new Entry((float) j, day.getData().getAirtem().getMin().get(j).getAirtem()));
                                arrayList9.add(Utils.strToDateLong("dd日",day.getData().getAirtem().getMax().get(j).getCreate_time()));

                            } else if (i == 1) {
                                arrayList7.add(new Entry((float) j, day.getData().getAirhum().getMax().get(j).getAirnum()));
                                arrayList8.add(new Entry((float) j, day.getData().getAirhum().getMin().get(j).getAirnum()));
                                arrayList9.add(Utils.strToDateLong("dd日",day.getData().getAirhum().getMax().get(j).getCreate_time()));


                            } else if (i == 2) {
                                arrayList7.add(new Entry((float) j, day.getData().getSoiltem().getMax().get(j).getSoiltem()));
                                arrayList8.add(new Entry((float) j, day.getData().getSoiltem().getMin().get(j).getSoiltem()));
                                arrayList9.add(Utils.strToDateLong("dd日",day.getData().getSoiltem().getMax().get(j).getCreate_time()));

                            } else if (i == 3) {
                                arrayList7.add(new Entry((float) j, day.getData().getSoilhum().getMax().get(j).getSoilhum()));
                                arrayList8.add(new Entry((float) j, day.getData().getSoilhum().getMin().get(j).getSoilhum()));
                                arrayList9.add(Utils.strToDateLong("dd日",day.getData().getSoilhum().getMax().get(j).getCreate_time()));

                            } else if (i == 4) {
                                arrayList7.add(new Entry((float) j, day.getData().getIllumination().getMax().get(j).getIllumination()));
                                arrayList8.add(new Entry((float) j, day.getData().getIllumination().getMin().get(j).getIllumination()));
                                arrayList9.add(Utils.strToDateLong("dd日",day.getData().getIllumination().getMax().get(j).getCreate_time()));

                            }

                        }
                        NodeListDetail.this.setChartCreate(arrayList7, arrayList8,arrayList9);
                    }
                }
            });

        }  else {
            final ArrayList<Entry> arrayList10 = Daylist1;
            final ArrayList<Entry> arrayList11 = Daylist2;
            final ArrayList<String> arrayList12 = new ArrayList<>();
            final int i7 = type2;
            OkHttpHelper.Get(url4, new Callback() {
                @Override
                public void onFailure(Call call, IOException e) {

                }

                @Override
                public void onResponse(Call call, Response response) throws IOException {
                    ChartLineYear year = (ChartLineYear) new Gson().fromJson(response.body().string(), ChartLineYear.class);
                    arrayList10.clear();
                    arrayList11.clear();
                    arrayList12.clear();
                    if (year.getCode() == 200) {
                        for (int j = 0; j < year.getData().getAirtem().getMax().size(); j++) {
                            int i = i7;
                            if (i == 0) {
                                arrayList10.add(new Entry((float) j, year.getData().getAirtem().getMax().get(j).getMonth()));
                                arrayList11.add(new Entry((float) j, year.getData().getAirtem().getMin().get(j).getMonth()));

                            } else if (i == 1) {
                                arrayList10.add(new Entry((float) j, year.getData().getAirhum().getMax().get(j).getMonth()));
                                arrayList11.add(new Entry((float) j,year.getData().getAirhum().getMin().get(j).getMonth()));
                            } else if (i == 2) {
                                arrayList10.add(new Entry((float) j, year.getData().getSoiltem().getMax().get(j).getMonth()));
                                arrayList11.add(new Entry((float) j, year.getData().getSoiltem().getMin().get(j).getMonth()));
                            } else if (i == 3) {
                                arrayList10.add(new Entry((float) j, year.getData().getSoilhum().getMax().get(j).getMonth()));
                                arrayList11.add(new Entry((float) j, year.getData().getSoilhum().getMin().get(j).getMonth()));
                            } else if (i == 4) {
                                arrayList10.add(new Entry((float) j, year.getData().getIllumination().getMax().get(j).getMonth()));
                                arrayList11.add(new Entry((float) j, year.getData().getIllumination().getMin().get(j).getMonth()));
                            }

                        }
                        NodeListDetail.this.setChartCreate(arrayList10, arrayList11,arrayList12);
                    }

                }
            });
        }

    }

    /* access modifiers changed from: private */
    public void setChartCreate(ArrayList<Entry> list1, ArrayList<Entry> list2, final ArrayList<String> list3) {
        Log.i("TAG2222222", "setChartCreate: "+list3);
        Log.i("TAG2222222", "setChartCreate: "+list2);
        this.progressDialog.dismiss();
        final ArrayList list = new ArrayList();
        LineDataSet lineDataSet1 = null;
        LineDataSet lineDataSet2 = null;
        int i = this.type;
        if (i == 0) {
            lineDataSet1 = new LineDataSet(list1, "空气温度最大值");
            lineDataSet2 = new LineDataSet(list2, "空气温度最小值");
        } else if (i == 1) {
            lineDataSet1 = new LineDataSet(list1, "空气湿度最大值");
            lineDataSet2 = new LineDataSet(list2, "空气湿度最小值");
        } else if (i == 2) {
            lineDataSet1 = new LineDataSet(list1, "土壤温度最大值");
            lineDataSet2 = new LineDataSet(list2, "土壤温度最小值");
        } else if (i == 3) {
            lineDataSet1 = new LineDataSet(list1, "土壤湿度最大值");
            lineDataSet2 = new LineDataSet(list2, "土壤湿度最小值");
        } else if (i == 4) {
            lineDataSet1 = new LineDataSet(list1, "光照强度最大值");
            lineDataSet2 = new LineDataSet(list2, "光照强度最小值");
        }
        lineDataSet1.setColor(Color.parseColor("#e4a9bd"));
        lineDataSet2.setColor(Color.parseColor("#8ac1bb"));
        lineDataSet1.setLineWidth(3.0f);
        lineDataSet2.setLineWidth(3.0f);
        list.add(lineDataSet1);
        list.add(lineDataSet2);
        this.lineChart.setData(new LineData((List<ILineDataSet>) list));
        this.lineChart.notifyDataSetChanged();
        this.lineChart.invalidate();
        this.lineChart.getDescription().setEnabled(false);
        this.lineChart.getAxisRight().setEnabled(false);
        XAxis xAxis = this.lineChart.getXAxis();
        xAxis.setLabelCount(365, false);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setGranularity(1);
        xAxis.setDrawGridLines(false);
        IAxisValueFormatter formatter = new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                Log.e("TAG4444444444", "----->getFormattedValue: " + value);
                //设置 xAxis.setGranularity(1);后 value是从0开始的，每次加1，

                int index = (int) value;
                if (index < 0 || index >= list3.size()) {
                    return index+"";
                } else {
                    return list3.get(index);
                }

            }
        };
        xAxis.setValueFormatter(formatter);


    }



    private void initViews() {
        this.lineChart = (LineChart) findViewById(R.id.lin);
        this.radioButton1 = (RadioButton) findViewById(R.id.node_rb1);
        this.radioButton1.setChecked(true);
        this.airtem = (RadioButton) findViewById(R.id.airtem);
        this.airtem.setChecked(true);
        this.airnum = (RadioButton) findViewById(R.id.airnum);
        this.soilhum = (RadioButton) findViewById(R.id.soilhum);
        this.soiltem = (RadioButton) findViewById(R.id.soiltem);
        this.illumination = (RadioButton) findViewById(R.id.illumination);
        this.create_time = (TextView) findViewById(R.id.time);
        this.create_time.setText(getIntent().getStringExtra("time"));
        this.switchOpen = (Switch) findViewById(R.id.switchOpen);
        this.airHumMin = (EditText) findViewById(R.id.air_hum_min);
        this.airHumMax = (EditText) findViewById(R.id.air_hum_max);
        this.airTemMin = (EditText) findViewById(R.id.air_tem_min);
        this.airTemMax = (EditText) findViewById(R.id.air_tem_max);
        this.soilHumMin = (EditText) findViewById(R.id.soil_hum_min);
        this.soilHumMax = (EditText) findViewById(R.id.soil_hum_max);
        this.soilTemMin = (EditText) findViewById(R.id.soil_tem_min);
        this.soilTemMax = (EditText) findViewById(R.id.soil_tem_max);
        this.illuminaionMin = (EditText) findViewById(R.id.illumination_min);
        this.illuminaionMax = (EditText) findViewById(R.id.illumination_max);
        this.node_radio_group = (RadioGroup) findViewById(R.id.node_radio_group);
        this.setChartlineRg = (RadioGroup) findViewById(R.id.set_chartline_rg);
        this.context = this;
        getSupportActionBar().setTitle((CharSequence) getIntent().getStringExtra("title"));
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
}
